using System;
using UnityEngine;

namespace hole.defaultgame
{
	public class UIManager : BaseUIManager
	{
		[Serializable]
		public class EditorReferences
		{
			[Header("Game")]
			public GameObject gameGameObject;

			public UIDeath death;

			public UITutorial tutorial;

			public UICountdown countdown;

			public UIRealTimeRanking ranking;

			public UITimer timer;

			public UICounter killCounter;

			public UIIndicatorManager indicators;

			public UIFloatingText floatingText;

			public UIRemainingTime remainingTimeAlert;

			public UITimer finalRemainingTimeAlert;

			[Header("GameOver")]
			public GameObject gameOverGameObject;

			public UIGameOverTimer gameOver;

			[Header("Loading")]
			public UILoading loading;
		}

		public static UIManager Instance;

		[SerializeField]
		public EditorReferences references = new EditorReferences();

		public UIDeath DeathComponent => references.death;

		public UICountdown CountdownComponent => references.countdown;

		public UIRealTimeRanking RankingComponent => references.ranking;

		public UITimer TimerComponent => references.timer;

		public UICounter KillCounterComponent => references.killCounter;

		public UIIndicatorManager IndicatorsComponent => references.indicators;

		public UIFloatingText FloatingTextComponent => references.floatingText;

		public UIGameOverTimer GameOverComponent => references.gameOver;

		public UILoading LoadingComponent => references.loading;

		private void Awake()
		{
			Instance = this;
		}

		public void OnGameInit()
		{
			references.gameGameObject.SetActive(value: false);
			references.gameOverGameObject.SetActive(value: false);
			references.loading.Show();
			references.remainingTimeAlert.gameObject.SetActive(value: false);
			references.finalRemainingTimeAlert.gameObject.SetActive(value: false);
			references.tutorial.gameObject.SetActive(value: false);
			DeathComponent.gameObject.SetActive(value: false);
			RankingComponent.gameObject.SetActive(value: false);
			TimerComponent.gameObject.SetActive(value: false);
			KillCounterComponent.gameObject.SetActive(value: false);
		}

		public void OnGameStart()
		{
			references.gameGameObject.SetActive(value: true);
			references.loading.Hide();
			references.tutorial.Show();
		}

		public void OnGameEnd()
		{
			references.gameGameObject.SetActive(value: false);
			references.gameOverGameObject.SetActive(value: true);
			references.gameOver.Show();
		}

		public void AlertRemainingTime(int second)
		{
			if (second > 5)
			{
				references.remainingTimeAlert.ShowRemainingTime(second);
				return;
			}
			references.finalRemainingTimeAlert.gameObject.SetActive(value: true);
			references.finalRemainingTimeAlert.SetTime(second);
		}
	}
}
